<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>文章审核</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function submitForm() {
            var form = document.getElementById("myform");
            form.submit();
        }

        function Info() {
            //var id = $(obj).attr("id");
            //var id = $("input:checkbox:checked").val();
            var tableRow = $("input:checkbox:checked")[0].parentElement.parentElement;
            //var id = $("input:checkbox:checked").val();
            //获取表格中的一行数据
            var title = tableRow.cells[1].innerText;
            var cl = tableRow.cells[2].innerText;
            var message = tableRow.cells[6].innerText;
            //alert("=="+title+"=="+cl+"=="+message)
            //向模态框中传值
            $('#title').val(title);
            $('#cl').val(cl);
            $('#message-text').val(message);
        }
    </script>
    <style>
        .table th, .table td {
            text-align: center;
            vertical-align: middle !important;
        }

        .col-md-8 {
            padding-left: 0rem;
        }

        .col-md-12 {
            padding-top: 1.25rem;
        }
    </style>
</head>
<body>

<div class="container-fluid">
    <%--    标题--%>
    <div class="col-md-11">
        <h3>文章审核</h3>
        <HR style="FILTER: alpha(opacity=100,finishopacity=0,style=3)" width="80%" color=#987cb9 SIZE=3>
    </div>
    <%--    查询栏目--%>
    <form method="post" action="SearchServlet" id="myform">
        <div class="col-md-8">
            <div class="col-lg-3">
                <div class="input-group">
                    <span class="input-group-addon">状态:</span>
                    <select onchange="submitForm()" class="form-control" name="status">
                        <option value="">--请选择--
                        <option value="通过">通过</option>
                        <option value="不通过">不通过</option>
                    </select>
                </div>
            </div>
        </div>
    </form>
    <%--功能栏目--%>
    <div class="col-md-4 text-right">
        <p id="pass" class="btn btn-primary">审核通过</p>
        <p id="passOff" class="btn btn-danger">审核不通过</p>
        <a id="view" href="#" class="btn btn-success" data-toggle="modal" data-target="#example"
           data-whatever="@getbootstrap" onclick="Info()">查看</a>
    </div>

    <%--表格--%>
    <form action="AuditServlet" method="post">
        <div class="col-md-12">
            <table id="table" width="100%" class="table table-bordered table-striped table-hover">
                <tr>
                    <td><input type="checkbox"/></td>
                    <td colspan="2">标题</td>
                    <td>发表时间</td>
                    <td>状态</td>
                    <td>浏览数</td>
                    <td>点赞数</td>
                </tr>
                <c:forEach items="${pageBean.list }" var="list">
                    <tr>
                        <td><input type="checkbox" value="${list.aid}"/></td>
                        <td colspan="2">${list.title }</td>
                        <td>${list.isstime }</td>
                        <td>${list.status }</td>
                        <td>${list.viewcount }</td>
                        <td>${list.like }</td>
                        <td hidden>${list.conten}</td>
                    </tr>
                </c:forEach>
                <%-- <c:forEach items="${list }" var="list">
                     <tr>
                         <td><input type="checkbox" value="${list.aid}"/></td>
                         <td colspan="2">${list.title }</td>
                         <td>${list.isstime }</td>
                         <td>${list.status }</td>
                         <td>${list.viewcount }</td>
                         <td>${list.like }</td>
                     </tr>
                 </c:forEach>--%>
            </table>
        </div>
    </form>
</div>

<%--模态框--%>
<div class="modal fade" id="example" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="exampleModalLabel">文章详情</h4>
            </div>

            <div class="modal-body">
                <form method="post" action="ViewServlet">
                    <div class="form-group">
                        <label for="title" class="control-label">标题:</label>
                        <input type="text" class="form-control" id="title">
                    </div>

                    <div class="form-group">
                        <label for="cl" class="control-label">栏目:</label>
                        <input type="text" class="form-control" id="cl">
                    </div>

                    <div class="form-group">
                        <label for="message-text" class="control-label">内容:</label>
                        <textarea class="form-control" id="message-text"></textarea>
                    </div>
                </form>
            </div>

            <div class="modal-footer ">
                <center>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <!-- <button type="button" class="btn btn-primary">添加</button> -->
                </center>
            </div>
        </div>
    </div>
</div>


<!--分页 -->
<div>
    <nav style="text-align: center;" aria-label="Page navigation" class="navbar-fixed-bottom">
        <ul class="pagination ">

            <c:if test="${pageBean.currentPage !=1 }">
                <li>
                    <a href="AuditServlet?currentPage=${pageBean.currentPage-1 }" aria-label="Previous">
                        <span aria-hidden="tru">&laquo;上一页</span>
                    </a>
                </li>
            </c:if>

            <li>
                <c:forEach begin="1" end="${pageBean.totalPage }" var="i">
                    <c:if test="${pageBean.currentPage == i }">
                        <a href="#">${i }</a>
                    </c:if>
                    <c:if test="${pageBean.currentPage != i }">
                        <a href="AuditServlet?currentPage=${i }">${i }</a>
                    </c:if>
                </c:forEach>
            </li>
            <li>
                <c:if test="${pageBean.currentPage !=pageBean.totalPage }">
                    <a href="AuditServlet?currentPage=${pageBean.currentPage+1 }" aria-label="Next">
                        <span aria-hidden="true">下一页&raquo;</span>
                    </a>
                </c:if>
            </li>
        </ul>
    </nav>
</div>
</body>
</html>
